{include file="public/header" /}
<body class="gray-bg">
<div class="layui-fluid layui-col-md12">
    <div class="layui-card">
        <div class="layui-card-header">编辑导航</div>
        <div class="layui-card-body layui-form">
            <div class="layui-row layui-col-space10 layui-form-item ">
                <input type="hidden" name="id" value="{$version.id}">
                <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                    <label class="layui-form-label">旧版本号</label>
                    <div class="layui-input-block">
                        <input type="text" name="oldversion" value="{$version.oldversion}" lay-verify="required" placeholder="旧版本号" class="layui-input ">
                    </div>
                </div>
                <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                    <label class="layui-form-label">新版本号</label>
                    <div class="layui-input-block">
                        <input type="text" name="newversion" value="{$version.newversion}" lay-verify="required" placeholder="新版本号" class="layui-input ">
                    </div>
                </div>
                <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                    <label class="layui-form-label">升级内容</label>
                    <div class="layui-input-block">
                        <textarea name="content" placeholder="升级内容" lay-verify="extra" class="layui-textarea">{$version.content}</textarea>
                    </div>
                </div>
                <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                    <label class="layui-form-label">状态</label>
                    <div class="layui-input-block">
                        <input type="radio" name="status" value="1" title="开启" {if condition="$version['status'] == 1"}  checked {/if}>
                        <input type="radio" name="status" value="2" title="禁用" {if condition="$version['status'] == 2"}  checked {/if}>
                    </div>
                </div>
                <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
                        </button>
                        <button class="layui-btn layui-btn-primary" onclick="wk.layer_close('close')">关闭</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    layui.use(['form','element'], function() {
        var form = layui.form
            , element = layui.element

        form.verify({
            orderby:[/^(0|[1-9]\d*)$/,'排序值只能为非负整数']
        });

        form.on('submit(component-form-element)', function (data) {
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('edit_ver')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        layer.msg(res.msg,{icon:1,time:1500,shade:0.1},function(index){
                            setTimeout(function () {
                                wk.layer_close();
                                window.location.href="{:url('Version/index')}";
                            },100);
                        })
                    } else {
                        $(".layui-btn").removeClass('layui-disabled').removeAttr('disabled');
                        wk.error(res.msg);
                        return false;
                    }
                }
            })
        });
    });
</script>
</body>
</html>